<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>菜单详情</title>
  <link rel="stylesheet" href="./css/style.css" />
</head>

<body>
  <h3 class="big-tit">菜谱详情</h3>
  <div class="container flex-box">
    <div class="left">
      <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
    </div>
    <div class="right">
      <h3>菜谱名称</h3>
      <p>
        菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息菜谱描述信息
      </p>
      <h5>下面列表是菜谱中美味的菜品哦！</h5>
    </div>
  </div>
  <ul class="list-box">
    <li>
      <a href="detail.html">
        <img src="http://yun.itheima.com/Upload/Images/20220627/62b924298e658.jpg" alt="" />
        <h3>菜单名称</h3>
      </a>
    </li>

  </ul>
</body>
<script src="../jquery.js"></script>
<script>


let imgs=localStorage.getItem('imgs')
$('.left img').attr('src',imgs)
let bb=[]
  let n = localStorage.getItem('id')
  let kk = JSON.parse(localStorage.getItem('kk'))
  // console.log(kk);
  let m = localStorage.getItem('k')
  // console.log(n);
  $.ajax({
    method: 'get',
    url: `http://124.223.14.236:3001/api/recipe/${m}`,
    success({ data }) {
      // console.log(data);
      $('.right p').html(data.description)
    }
  })
  $.ajax({
    method: 'get',
    url: `http://124.223.14.236:3001/api/recipeInfo?recipe_id=6251654`,
    success(res) {
      console.log(res,8888);
      res.data.splice(10, 10)
      console.log(res.data);
     
      let mm = res.data.map(item => {
        bb.push(item.id)
        return `
        <li>
      <a href="detail.html">
        <img src="http://124.223.14.236:3001/public/${item.img}" title="${item.author}" />
        <h3>${item.title}</h3>
      </a>
    </li>
        `
      }).join('')
    
     
      $('.list-box').html(mm)
      console.log(bb);
      $('.list-box').on('click','li',function(e){
            localStorage.setItem('xuan',bb[$(this).index()])
           console.log(bb[$(this).index()]);
           localStorage.setItem('imgss',$(this).find('img').attr('src'))
        })
      // console.log(res.data);
      let nn = res.data.find(item => {
        return item.id === JSON.parse(n)
        console.log(nn);
        $('.big-tit').html(nn.title)
        $('.right h3').html(nn.title)
      })

    }
  })
</script>

</html>